/**
  ******************************************************************************
  * @file           : gv.h
  * @brief          : This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GLOBAL_VARIABLES_H
#define __GLOBAL_VARIABLES_H

#include "measbase.h"

#define GV_DISINPUT_MAX    16
#define GV_HOLDREG_MAX     GVHR_END+1

#define DI_LOCAL_ACTIVE    0
#define DI_LOCAL_DEACTIVE  1

/* 线圈类变量(外部读写) bit或flag等 */
typedef struct _GlobalVariables_CoilsStru
{
  Meas_ExternalControlsStru meas_ec;
}GlobalVariables_CoilsStru;

/* 离散类输入(外部只读) bit或flag等 */
typedef struct _GlobalVariables_DisinputStru
{
  Meas_InternalStateStru meas_is;
}GlobalVariables_DisinputStru;

/* 保持寄存器(外部读写) */
typedef struct _GlobalVariables_HoldregStru
{
  Meas_ParameterStru meas_pa;
}GlobalVariables_HoldregStru;

/* 输入寄存器(外部只读) */
typedef struct _GlobalVariables_IntputRegStru
{
  Meas_CalculateStru meas_ca;
  Meas_TemporaryStru meas_tp;
  Meas_AdRawStru     meas_ad;
}GlobalVariables_IntputRegStru;

/* 统一编址全局变量 */
typedef struct _GlobalVariablesStru
{
  GlobalVariables_CoilsStru     co;
  GlobalVariables_DisinputStru  di;
  GlobalVariables_IntputRegStru ir;
  GlobalVariables_HoldregStru   hr;
}GlobalVariablesStru;

extern GlobalVariablesStru gv;

/* TODO: 临时先在这儿声明 */
extern double meas_get_current_class_prod(GlobalVariablesStru *pgv);

#endif /* __GLOBAL_VARIABLES_H */
